package com.yanqu.road.entity.activity.suitang.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.activity.suitang.entity.barracks.CrossSuiTangBarracks;
import com.yanqu.road.entity.activity.suitang.entity.team.CrossSuiTangTeam;
import com.yanqu.road.entity.activity.suitang.entity.user.CrossSuiTangUserBaseInfo;
import com.yanqu.road.entity.activity.suitang.entity.user.CrossSuiTangUserRound;
import com.yanqu.road.utils.property.Property;

import java.sql.Types;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_c_suitang_user_data")
public class CrossSuiTangUserData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "商会分组ID", select = true, update = true)
    private int groupId;

    @FieldTypeAnnotation(desc = "玩家ID", update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "商会ID，来自unionJoin")
    private String unionUid = "";

    @FieldTypeAnnotation(desc = "门客数据总赚钱")
    private long patronsTotalAbility;

    @FieldTypeAnnotation(desc = "前 n 门客数量")
    private long patronsNSum;

    @FieldTypeAnnotation(desc = "门客总数")
    private long patronsTotalNum;

    @FieldTypeAnnotation(desc = "天赋加成带兵上限")
    private long soldierAddition;

    @FieldTypeAnnotation(desc = "队伍数据", sqlType = Types.LONGVARCHAR)
    private CrossSuiTangTeam team = new CrossSuiTangTeam();

    @FieldTypeAnnotation(desc = "兵营数据", sqlType = Types.LONGVARCHAR)
    private CrossSuiTangBarracks barracks = new CrossSuiTangBarracks();

    @FieldTypeAnnotation(desc = "玩家基础数据", sqlType = Types.LONGVARCHAR)
    private CrossSuiTangUserBaseInfo userBaseInfo = new CrossSuiTangUserBaseInfo(0, 0);

    @FieldTypeAnnotation(desc = "玩家轮次数据", sqlType = Types.LONGVARCHAR)
    private Map<Integer, CrossSuiTangUserRound> userRoundMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "被会长任命的职位，0没被任命")
    private int positionId;

    @FieldTypeAnnotation(desc = "战功")
    private long zhanGong;
    @FieldTypeAnnotation(desc = "战功变化时间")
    private long zhanGongTime;

    @FieldTypeAnnotation(desc = "玩家领取的军资")
    private int receiveJunZi;
    @FieldTypeAnnotation(desc = "玩家当前军资")
    private int curJunZi;

    @FieldTypeAnnotation(desc = "红点", sqlType = Types.LONGVARCHAR)
    private Map<Integer, Long> redDotMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "马")
    private int horseId;

    // 不入库
    private long lastSyncPatronsTime;
    private long lastReqTime;

    @FieldTypeAnnotation(desc = "自动设置信息")
    private CrossSuiTangAutoSettingData autoSettingData = new CrossSuiTangAutoSettingData();

    @FieldTypeAnnotation(desc = "待领奖的奖励")
    private Property waitReward = new Property();

    // =============================

    public CrossSuiTangUserData() {
    }

    public static CrossSuiTangUserData initCrossSuiTangUserData(int activityId, int groupId, long userId) {
        CrossSuiTangUserData crossTongBingUserData = new CrossSuiTangUserData();
        crossTongBingUserData.setActivityId(activityId);
        crossTongBingUserData.setGroupId(groupId);
        crossTongBingUserData.setUserId(userId);
        crossTongBingUserData.setTeam(new CrossSuiTangTeam());
        crossTongBingUserData.setHorseId(1);
        crossTongBingUserData.setAutoSettingData(new CrossSuiTangAutoSettingData());
        crossTongBingUserData.setInsertOption();
        return crossTongBingUserData;
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        if (this.groupId != groupId) {
            this.groupId = groupId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public String getUnionUid() {
        return unionUid;
    }

    public void setUnionUid(String unionUid) {
        if (unionUid == null) {
            return;
        }
        if (this.unionUid == null || !this.unionUid.equals(unionUid)) {
            this.unionUid = unionUid;
            setOp(DataStatus.Update);
        }
    }

    public long getPatronsTotalAbility() {
        return patronsTotalAbility;
    }

    public void setPatronsTotalAbility(long patronsTotalAbility) {
        if (this.patronsTotalAbility != patronsTotalAbility) {
            this.patronsTotalAbility = patronsTotalAbility;
            setOp(DataStatus.Update);
        }
    }

    public long getPatronsNSum() {
        return patronsNSum;
    }

    public void setPatronsNSum(long patronsNSum) {
        this.patronsNSum = patronsNSum;
    }

    public long getPatronsTotalNum() {
        return patronsTotalNum;
    }

    public void setPatronsTotalNum(long patronsTotalNum) {
        if (this.patronsTotalNum != patronsTotalNum) {
            this.patronsTotalNum = patronsTotalNum;
            setOp(DataStatus.Update);
        }
    }

    public long getSoldierAddition() {
        return soldierAddition;
    }

    public void setSoldierAddition(long soldierAddition) {
        if (this.soldierAddition != soldierAddition) {
            this.soldierAddition = soldierAddition;
            setOp(DataStatus.Update);
        }
    }

    public CrossSuiTangTeam getTeam() {
        return team;
    }

    public void setTeam(CrossSuiTangTeam team) {
        if (null == team) {
            return;
        }
        if (this.team == null || !this.team.equals(team)) {
            this.team = team;
            setOp(DataStatus.Update);
        }
    }

    public CrossSuiTangBarracks getBarracks() {
        return barracks;
    }

    public void setBarracks(CrossSuiTangBarracks barracks) {
        if (null == barracks) {
            return;
        }
        if (this.barracks == null || !this.barracks.equals(barracks)) {
            this.barracks = barracks;
            setOp(DataStatus.Update);
        }
    }

    public CrossSuiTangUserBaseInfo getUserBaseInfo() {
        return userBaseInfo;
    }

    public void setUserBaseInfo(CrossSuiTangUserBaseInfo userBaseInfo) {
        if (null == userBaseInfo) {
            return;
        }
        if (this.userBaseInfo == null || !this.userBaseInfo.equals(userBaseInfo)) {
            this.userBaseInfo = userBaseInfo;
            setOp(DataStatus.Update);
        }
    }

    public java.util.Map<java.lang.Integer, com.yanqu.road.entity.activity.suitang.entity.user.CrossSuiTangUserRound> getUserRoundMap() {
        return userRoundMap;
    }

    public void setUserRoundMap(java.util.Map<java.lang.Integer, com.yanqu.road.entity.activity.suitang.entity.user.CrossSuiTangUserRound> userRoundMap) {
        if (null == userRoundMap) {
            return;
        }
        if (this.userRoundMap == null || !this.userRoundMap.equals(userRoundMap)) {
            this.userRoundMap = userRoundMap;
            setOp(DataStatus.Update);
        }
    }

    public int getPositionId() {
        return positionId;
    }

    public void setPositionId(int positionId) {
        if (this.positionId != positionId) {
            this.positionId = positionId;
            setOp(DataStatus.Update);
        }
    }

    public long getZhanGong() {
        return zhanGong;
    }

    public void setZhanGong(long zhanGong) {
        if (this.zhanGong != zhanGong) {
            this.zhanGong = zhanGong;
            setOp(DataStatus.Update);
        }
    }

    public long getZhanGongTime() {
        return zhanGongTime;
    }

    public void setZhanGongTime(long zhanGongTime) {
        if (this.zhanGongTime != zhanGongTime) {
            this.zhanGongTime = zhanGongTime;
            setOp(DataStatus.Update);
        }
    }

    public int getReceiveJunZi() {
        return receiveJunZi;
    }

    public void setReceiveJunZi(int receiveJunZi) {
        if (this.receiveJunZi != receiveJunZi) {
            this.receiveJunZi = receiveJunZi;
            setOp(DataStatus.Update);
        }
    }

    public int getCurJunZi() {
        return curJunZi;
    }

    public void setCurJunZi(int curJunZi) {
        if (this.curJunZi != curJunZi) {
            this.curJunZi = curJunZi;
            setOp(DataStatus.Update);
        }
    }

    public java.util.Map<java.lang.Integer, java.lang.Long> getRedDotMap() {
        return redDotMap;
    }

    public void setRedDotMap(java.util.Map<java.lang.Integer, java.lang.Long> redDotMap) {
        if (null == redDotMap) {
            return;
        }
        if (this.redDotMap == null || !this.redDotMap.equals(redDotMap)) {
            this.redDotMap = redDotMap;
            setOp(DataStatus.Update);
        }
    }

    public int getHorseId() {
        return horseId;
    }

    public void setHorseId(int horseId) {
        if (this.horseId != horseId) {
            this.horseId = horseId;
            setOp(DataStatus.Update);
        }
    }

    public CrossSuiTangAutoSettingData getAutoSettingData() {
        return autoSettingData;
    }

    public void setAutoSettingData(CrossSuiTangAutoSettingData autoSettingData) {
        if (autoSettingData == null) {
            return;
        }
        this.autoSettingData = autoSettingData;
        setOp(DataStatus.Update);
    }

    public Property getWaitReward() {
        return waitReward;
    }

    public void setWaitReward(Property waitReward) {
        if (waitReward == null) {
            return;
        }
        this.waitReward = waitReward;
        setOp(DataStatus.Update);
    }

    public void addWaitReward(Property addWaitReward) {
        if (addWaitReward == null) {
            return;
        }
        this.waitReward.addProperty(addWaitReward);
        setOp(DataStatus.Update);
    }

    // ============= 不入库 =============

    public long getLastSyncPatronsTime() {
        return lastSyncPatronsTime;
    }

    public void setLastSyncPatronsTime(long lastSyncPatronsTime) {
        this.lastSyncPatronsTime = lastSyncPatronsTime;
    }

    public long getLastReqTime() {
        return lastReqTime;
    }

    public void setLastReqTime(long lastReqTime) {
        this.lastReqTime = lastReqTime;
    }
}
